package com.qi.fiveinrow;

import java.awt.Image;
import java.util.Objects;
import javax.imageio.ImageIO;

/**
 * 棋子
 *
 * @author Administrator
 */
public class Chess {

    Image image = null;
    int x = -100;

    int y = -100;
    String color = Consts.BLACK;

    public Chess(int x, int y, String color) {
        this.x = x;
        this.y = y;
        this.color = color;
        try {
            if (this.color.equals(Consts.BLACK)) {
                image = ImageIO.read(Objects.requireNonNull(ClassLoader.getSystemResourceAsStream("images/black.jpg")));
            } else if (this.color.equals(Consts.WHITE)) {
                image = ImageIO.read(Objects.requireNonNull(ClassLoader.getSystemResourceAsStream("images/white.jpg")));
            }
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getX0() {
        return (int) (x * Consts.LENGTH + 30);
    }

    public int getY0() {
        return (int) (y * Consts.LENGTH + 30);
    }
}
